package com.shuma.common.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LogMqConfig {

    public static final String EXCHANGE = "log.topic";
    public static final String ROUTING_KEY = "log.action";
    public static final String QUEUE = "log.queue";

    @Bean
    public TopicExchange logExchange() {
        return new TopicExchange(EXCHANGE,true,false);
    }

    @Bean
    public Queue logQueue() {
        return new Queue(QUEUE,true);
    }

    @Bean
    public Binding logBinding() {
        return BindingBuilder.bind(logQueue()).to(logExchange()).with(ROUTING_KEY);
    }
}
